package main

import (
	"flag"
	"fmt"
	"net"
	"time"
)

func main() {

	addr := flag.String("addr", "218.5.69.74:16880", "telnet 地址")

	flag.Parse()

	fmt.Printf("telnet addr: %v", *addr)
	fmt.Println()
	//addr := "218.5.69.74:16880"
	success := 0
	error := 0
	for {
		time.Sleep(time.Duration(time.Second * 1))

		//	addr := "wx21bb14732dc33da4.custom.brtbeacon.com.cn:10100"
		conn, err := net.DialTimeout("tcp", *addr, time.Duration(300)*time.Second)
		if err != nil {
			error = error + 1
			fmt.Printf("telnet [%s] error 成功:[%d]次, 失败[%d]次", *addr, success, error)
			fmt.Println()
		} else {
			success = success + 1
			fmt.Printf("telnet [%s] success 成功:[%d]次, 失败[%d]次", *addr, success, error)
			fmt.Println()
			conn.Close()
		}

	}

}
